package com.younion.action.manage;

import java.util.List;
import java.util.Map;

import org.apache.commons.beanutils.PropertyUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.shiro.authz.annotation.RequiresPermissions;

import com.google.common.collect.Maps;
import com.younion.business.IMemberCardUpgradeLogService;
import com.younion.common.base.BaseAction;
import com.younion.common.paginator.Paginator;
import com.younion.vo.MemberCardUpgradeLogVO;

import cpcns.jhsks.util.MapCollectionUtils;

public class MemberCardUpgradeLogAction extends BaseAction {
	
	private static final long serialVersionUID = -2265980910201288366L;

	protected static final Log logger = LogFactory.getLog(MemberCardUpgradeLogAction.class);
	
	private MemberCardUpgradeLogVO memberCardUpgradeLogVO;
	
	private IMemberCardUpgradeLogService memberCardUpgradeLogService;
	
	private List<MemberCardUpgradeLogVO> memberCardUpgradeLogList;
	
	@SuppressWarnings("unchecked")
	@RequiresPermissions("listMemberCardUpgradeLog")
	public String listMemberCardUpgradeLog() {
		try {
			Map paramMap = Maps.newHashMap();
			if (this.memberCardUpgradeLogVO != null) {
				paramMap = MapCollectionUtils.removeEmptyEntry(PropertyUtils.describe(this.memberCardUpgradeLogVO));
			}
			if(getSessionUser().getCustomer() != null){
				paramMap.put("customerId", getSessionUser().getCustomer().getId());
			}
			// 获取总记录数
			int total = this.memberCardUpgradeLogService.selectCountByMap(paramMap);
			// 根据总记录数获取分页对象
			Paginator paginator = this.getPaginator(total);
			this.memberCardUpgradeLogList = this.memberCardUpgradeLogService.selectForPage(paramMap, paginator);
			// 保存分页对象
			this.savaPaginator(paginator);
		} catch (Exception e) {
			logger.error(e.getMessage(), e);
		}
		return SUCCESS;
	}

	public MemberCardUpgradeLogVO getMemberCardUpgradeLogVO() {
		return memberCardUpgradeLogVO;
	}

	public void setMemberCardUpgradeLogVO(
			MemberCardUpgradeLogVO memberCardUpgradeLogVO) {
		this.memberCardUpgradeLogVO = memberCardUpgradeLogVO;
	}

	public List<MemberCardUpgradeLogVO> getMemberCardUpgradeLogList() {
		return memberCardUpgradeLogList;
	}

	public void setMemberCardUpgradeLogService(
			IMemberCardUpgradeLogService memberCardUpgradeLogService) {
		this.memberCardUpgradeLogService = memberCardUpgradeLogService;
	}

}
